package com.baizhi.service;

import com.baizhi.dao.TUserMapper;
import com.baizhi.entity.TUser;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@Transactional
public class TUserServiceImpl implements TUserService {

    @Autowired
    private TUserMapper tUserMapper;

    @Override
    public void register(TUser tUser) {
        tUserMapper.insertSelective(tUser);
    }

    @Override
    public void delete(Integer id) {
        tUserMapper.deleteByPrimaryKey(id);
    }

    @Override
    public void update(TUser tUser) {
        tUserMapper.updateByPrimaryKeySelective(tUser);
    }

    @Override
    @Transactional(propagation = Propagation.SUPPORTS, readOnly = true)
    public List<TUser> showAll() {
        List<TUser> tUsers = tUserMapper.selectAll();
        return tUsers;
    }

    @Override
    @Transactional(propagation = Propagation.SUPPORTS, readOnly = true)
    public TUser selectByID(Integer id) {
        TUser tUser = tUserMapper.selectByPrimaryKey(id);
        return tUser;
    }
}
